package cn.ml.gaoJi.jiHe.list;



import java.util.ArrayList;
import java.util.Iterator;

public class MyArrayListTest {
    public static void main(String[] args) {
        NewsTitle title1 = new NewsTitle(1,"1-北京晴天了1","admid");
        NewsTitle title2 = new NewsTitle(2,"2-北京晴天了2","admid");
        NewsTitle title3 = new NewsTitle(3,"3-北京晴天了3","admid");
        NewsTitle title4 = new NewsTitle(4,"4-北京晴天了4","admid");
        NewsTitle title5 = new NewsTitle(5,"5-北京晴天了5","admid");
        NewsTitle title6 = new NewsTitle(6,"6-北京晴天了5","admid");
        NewsTitle title7 = new NewsTitle(7,"7-北京晴天了5","admid");

        ArrayList<NewsTitle> list = new ArrayList<>();
        list.add(title1);
        list.add(title2);
        list.add(title3);
        list.add(1,title4);
        System.out.println("list自己---"+list);

        for (NewsTitle s:list){
            //NewsTitle title = (NewsTitle) s;
            System.out.println(s.getId()+s.getTitle());
        }
        System.out.println("888888888888888888888888");
        for(int i=0;i<list.size();i++){
            //NewsTitle title = (NewsTitle) list.get(i);
            System.out.println(list.get(i).getId()+list.get(i).getTitle());
        }

        System.out.println("******************************");
        Iterator<NewsTitle> itor = list.iterator();
        while (itor.hasNext()){
            NewsTitle title =  itor.next();
            //System.out.println(itor.next().getId()+itor.next().getTitle());
            System.out.println(title.getId()+title.getTitle());
        }

    }
}
